package com.anzia.demo03;

/**
 *@ClassName Outer
 *@Description
 *@Author Anzia.
 *@Date 2021/4/11 12:13
 *@Version 1.0
 **/
public class Outer {
    private String name = "刘德华";
    private int age = 35;

    public void show() {
        //定义局部变量
        String address = "深圳";

        //局部内部类：注意不能添加任何访问修饰符
        class Inner {
            //局部内部类的属性
            private String phone = "123456789";
            private String email = "123@qq.com";

            public void show2() {
                //访问外部类属性
                System.out.println(Outer.this.name);
                System.out.println(Outer.this.age);
                //访问内部类的属性
                System.out.println(this.phone);
                System.out.println(this.email);
                //访问局部变量，jdk1.7要求，变量必须是常量final，jdk1.8自动添加final
                System.out.println(address);
            }
        }
        //创建局部内部类对象
        Inner inner = new Inner();
        inner.show2();
    }
}